<?php

require('../../public/common.php');

checkLogin();

if (empty($_POST['name'] || empty($_POST['title']))) {return;}

$name = $_POST['name'];

$title = $_POST['title'];

$domain = $_POST['domain'];

$pc_url = $_POST['pc_url'];

$keyword = $_POST['keyword'];

$content_url = $_POST['content_url'];

$mobile_url = $_POST['mobile_url'];

$time = date('Y-m-d H:i:s');

$user = $_SESSION["user"];

$query = mysqli_query($connect, "insert into template values(null,'{$name}','{$title}','{$domain}','{$keyword}','{$pc_url}','{$mobile_url}','{$content_url}','{$time}');");

if (!$query)exit();

$ip = get_server_ip();

$query_history = mysqli_query($connect, "insert into history values(null,'{$ip}','{$user}','{$title}','{$domain}','{$keyword}','增加','{$pc_url}','{$mobile_url}','{$content_url}','{$time}');");

if (!$query_history) exit();

header("Location: ../../views/index/index.php");
